<?php


namespace App\Service\api;


use App\Common\RedisUtils;
use App\Common\Res;
use App\Common\SendMsgUtils;
use App\Common\StringUtils;
use App\Constants\ConstCode;
use App\Constants\ErrorCode;
use App\Model\form\AttachmentTrait;
use App\Model\form\MessageTalkTrait;
use App\Model\form\WeworkAccountTrait;
use App\Model\FriendTalk;
use App\Request\api\MessageRequest;
use Hyperf\Context\Context;
use Hyperf\DbConnection\Db;
use Hyperf\Utils\ApplicationContext;
use Psr\Container\ContainerExceptionInterface;
use Psr\Container\NotFoundExceptionInterface;
use Hyperf\Config\Annotation\Value;
use Psr\Http\Message\ServerRequestInterface;

class apiAccountService
{
    use StringUtils, Res, RedisUtils,
        SendMsgUtils, WeworkAccountTrait, AttachmentTrait, MessageTalkTrait;

    /**
     * @Value("commonset.hostUrl")
     */
    protected $hostUrl;

    /**
     * 聊天页面心跳
     * @param int $fd
     * @return array
     * @throws ContainerExceptionInterface
     * @throws NotFoundExceptionInterface
     */
    public function getOperationPop(int $fd): array
    {
        $login = $this->getChat(ConstCode::CHAT_TOKEN . $fd);
        if (!empty($login)) {
            $login = $this->setChat(ConstCode::CHAT_TOKEN . $fd, $login, 100);
            $data['code'] = ErrorCode::SUCCESS;
            $data['msg'] = '心跳成功';
        } else {
            $data['code'] = ErrorCode::ERROR;
            $data['msg'] = '心跳失败';
        }
        return $data;
    }

}